//Returns a velocity to apply in X and Z
function adjustVelocity(low, high)
{
	return ((((((2 * rand(low,high)) + 1) *rand(low,high)) + 1) * 0.005) - (((((2 * rand(low,high)) + 1) * rand(low,high)) + 1) * 0.005))/50;
}

//Returns an Acceleration to apply in Y
function adjustAccel(low, high)
{
	return (((((5 * rand(low,high)) + 5) * rand(low,high)) + 1) * 0.02)/100;
}

//Return a random color in the specified range (0-255) for a single channel
function randomColor(min,max)
{
	return Math.floor(rand(min,max))/255
}

//Give a particle new values
function genParticle(i, nonMoveAttrib) 
{
	particles[i].x = startingPos[0];
	particles[i].y = startingPos[1];
	particles[i].z = startingPos[2];
	
	particles[i].vx = adjustVelocity(2,14);
	particles[i].vz = adjustVelocity(2,14);
	
	particles[i].Dir = 1;
	particles[i].Accel = adjustAccel(2,11);
	particles[i].Decel = 0.0015;
	
	if (nonMoveAttrib == true) {
		particles[i].ScaleP = Math.floor(rand(0,12));
	
		particles[i].r = randomColor(0,255);
		particles[i].g = randomColor(0,80);
		particles[i].b = randomColor(0,80);
	}
}

//Use existing values to update the particle's information
function updateParticle(i)
{
	particles[i].y = particles[i].y + particles[i].Accel - particles[i].Decel;
	particles[i].Decel = particles[i].Decel + 0.0015;
	particles[i].x = particles[i].x + particles[i].vx;
	particles[i].z = particles[i].z + particles[i].vz;
}